package org.example.chain;

/**
 * 装饰器模式
 */
public abstract class AbstractHandler implements Handler {
    Handler nextHandler;

    @Override
    public Handler setNextHandler(Handler handler) {
        this.nextHandler = handler;
        return handler;
    }

    public abstract void execute();

    public void nextExecute() {
        if (nextHandler != null) {
            nextHandler.execute();
        } else {
            System.out.println("end");
        }
    }

    ;
}
